package com.df.barcodescaning.util;

import java.lang.reflect.Method;

/**
 * Created by G on 2018/4/10.
 */

public class DeviceUtils {

    public static int UHF = 0;
    public static int XY = 1;
    public static int M6E = 2;

    public static int getDeviceType() { //0:HF, 1:XUNYUAN, 2:M6E
        return Integer.parseInt(getDeviceSerialId());
    }

    private static String getDeviceSerialId(){
        String sn = "";
        try {
            Class cls = Class.forName("android.os.SystemProperties");
            Method method = cls.getMethod("get",String.class);
            sn =	(String) method.invoke(cls,"gsm.serial");
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (Exception e){}
        if(sn.trim().length() >= 10){    //eg:PWS4720G13117557
            try {
                String strSerial = sn.substring(8, 9);
                return strSerial;
            } catch (Exception e){
                return sn;
            }
        } else {
            return sn;
        }
    }
}
